home *** CD-ROM | disk | FTP | other *** search
/ Night Owl 6 / Night Owl's Shareware - PDSI-006 - Night Owl Corp (1990).iso / 016a / settime.zip / SETTIME.CPP next >
Text File  |  1991-10-01  |  1KB  |  34 lines

  1. // **************************************************************************
  2. //                               SETTIME.CPP
  3. //
  4. //   Written By:  Bob Marriott, ELAR Computer Systems
  5. //   Date:        09/30/91
  6. //
  7. //   Description: Reads the CMOS Real Time clock and updates the BIOS Time
  8. //                of day count.  This program should run on IBM AT's and 
  9. //                compatibles, however no warrenty is implied or expressed.
  10. //                This Program is released to the PUBLIC DOMAIN by its
  11. //                author.
  12. //
  13. //***************************************************************************
  14.  
  15. #include <dos.h>
  16.  
  17. #define RTCLOCK 0x1a
  18.  
  19. int main(void)
  20. {
  21.    struct  time t;               // record structure for system BIOS time call
  22.    union REGS regs;              // record structure for interrupt call
  23.  
  24.    regs.h.ah = 0x2;              // Read Real Time Clock
  25.    int86(RTCLOCK, ®s, ®s); // get Time from CMOS real time clock
  26.  
  27.    t.ti_hour = (regs.h.ch & 0xf) + (regs.h.ch >> 4)*10;    // convert CMOS time
  28.    t.ti_min = (regs.h.cl & 0xf) + (regs.h.cl >> 4)*10;  // from BCD to the
  29.    t.ti_sec = (regs.h.dh & 0xf) + (regs.h.dh >> 4)*10;  // BIOS record struct
  30.  
  31.    settime(&t);                  // set the BIOS time
  32.  
  33. };
  34.